Skip to content

Combat 2.1c: Let a damage request scale or add to the weapon's damage - #193

Merged
Travja merged 1 commit into
devfrom
claude/inspiring-gates-8dbmr0
Nov 12, 2026
Merged

Travja merged 1 commit into
devfrom
claude/inspiring-gates-8dbmr0

Conversation

@Travja

@Travja Travja commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Part of magemonkeystudio/divinity#365. Needed by Combat 2.2 (magemonkeystudio/divinity#370).

Why

A DamageRequest could say "add these amounts to the weapon's damage" or "use only these amounts". Two of Divinity's own dealers are neither: the damage action and area damage are full weapon swings with every damage type changed, by a flat amount or a percentage. Today they do that by temporarily editing the attacker's stats before dealing 1 damage, which can leak into the attacker's next swing (see magemonkeystudio/divinity#381).

A skill that deals "150% weapon damage" is the same shape, so this is useful to Fabled as well.

What is added

On DamageRequest.builder():

Method Meaning
weaponScale(factor) Multiply every damage type of the weapon. Default 1
weaponScale(type, factor) Multiply one type, in place of the general factor
weaponBonus(amount) Add to every damage type the weapon deals. May be negative. Default 0
weaponBonus(type, amount) Add to one type, in place of the general amount

On DamageRequest:

Method Meaning
adjustWeaponDamage(type, amount) The weapon's amount of that type after this request: amount * scale + bonus
getWeaponScale(type), getWeaponBonus(type) The values that apply to a type
getWeaponScale(), getWeaponBonus() The general values
adjustsWeaponDamage() Whether the request changes weapon damage at all
// Divinity's damage action, +5 to every type:
DamageRequest.builder().origin(DamageOrigin.EFFECT).source(damager).weaponBonus(5).build();

// Area damage at 50%:
DamageRequest.builder().origin(DamageOrigin.EFFECT).source(damager).weaponScale(0.5).build();

Rules

  • Scale first, then bonus. Divinity's dealers only ever use one of the two, so either order reproduces them. This order is the one that reads naturally ("half damage, plus 3").
  • A type the weapon does not deal stays at 0. A bonus never gives a weapon a damage type it does not have. This matches the damage action today.
  • The result may be negative when the bonus is. Codex does not clamp; the plugin doing the calculation decides, as it does today.
  • It only means something in ADD mode, where the weapon's damage is part of the hit. Codex carries the values in any mode and does not enforce that.
  • Type ids here are the calculating plugin's own, without a namespace (fire, not DIVINITY_fire), because they name the weapon's damage types, not a classification to be routed.
  • A scale must be a number and not negative; a bonus must be a number.

The arithmetic gives the same floating-point results as Divinity's current operators: d * 1 + bonus equals d + bonus, and d * scale + 0 equals d * scale.

Must not change

A request that sets none of this behaves exactly as before. Nothing else is touched.

Tests

mvn -DskipNms -pl codex-api,codex-core -am test, exit code 0. 8 new tests in DamageRequestTest, 0 failures, 0 skipped.

Break-it checks, one edit at a time, each restored. All were caught:

Break Caught by
Bonus applied to a type the weapon does not deal weaponBonus_doesNotGiveAWeaponADamageTypeItDoesNotDeal
Bonus applied before the scale weaponScaleAndBonus_scaleFirstThenAdd and one more
Per-type scale ignored weaponScaleAndBonus_forOneType_replaceTheOnesForEveryType
Per-type bonus ignored same
adjustsWeaponDamage ignores per-type values weaponScaleForOneTypeOnly_countsAsAnAdjustment

Generated by Claude Code

A request can now say that the attacker's weapon damage takes part in
the hit changed: multiplied by a factor, with an amount added, for
every damage type or for one. Divinity's damage action and area damage
are weapon swings of that kind, and a skill that deals a share of the
weapon's damage is too.

Additive. A request that sets none of this leaves the weapon's damage
as it is.

Part of magemonkeystudio/divinity#365

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FaEyTtryHphQWR4EVUMbsz
@Travja Travja added the build:minor label Nov 12, 2026 — with Claude
@Travja
Travja merged commit c412074 into dev Nov 12, 2026
2 of 3 checks passed
@Travja
Travja deleted the claude/inspiring-gates-8dbmr0 branch November 12, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants